﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_Login : System.Web.UI.Page
{
    ThanhVienController ThanhVienCTR = new ThanhVienController();
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable Employee = (DataTable)Session["Employee"];
        if (Session["Employee"] != null)
            Response.Redirect("default.aspx");
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        ThanhVienEntity ThanhVienE=new ThanhVienEntity();
        ThanhVienE.MatKhau=ThanhVienCTR.MD5(txtPassword.Text);
        ThanhVienE.TenDangNhap=txtUserName.Text;
        DataTable dtThanhvien= ThanhVienCTR.fnC_GetDataThanhVien(ThanhVienE);
        if (dtThanhvien.Rows.Count != 0 && bool.Parse(dtThanhvien.Rows[0]["quyen"].ToString()) == true)
        {
            Session["Employee"] = dtThanhvien;
            Response.Redirect("Default.aspx");
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alert",
           "alert('Đăng Nhập Không Thành Công!');", true);
        }


    }
}